package com.hzhr.iot.device.dao;

import com.hzhr.iot.device.dao.mapper.custom.CollectDeviceEntityCustomMapper;
import com.hzhr.iot.device.dao.mapper.generator.CollectDeviceEntityMapper;
import com.hzhr.iot.device.entity.CollectDeviceEntity;
import com.hzhr.iot.device.entity.ext.CollectDeviceEntityExt;
import com.hzhr.iot.device.queryModel.custom.CollectDeviceCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class CollectDeviceDao {
    @Autowired
    CollectDeviceEntityMapper collectDeviceEntityMapper;
    @Autowired
    CollectDeviceEntityCustomMapper collectDeviceEntityCustomMapper;

    public int insert(CollectDeviceEntity record) {
        if (record == null) return 0;
        int changeCount = collectDeviceEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = collectDeviceEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(CollectDeviceEntity record) {
        if (record == null) return 0;
        int changeCount = collectDeviceEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = collectDeviceEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public CollectDeviceEntity selectEntity(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceEntity> selectEntityList(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<CollectDeviceEntity> entityList = new ArrayList<>();
        for (CollectDeviceEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public CollectDeviceEntityExt selectExt(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceEntityExt> selectExtList(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public CollectDeviceEntityExt selectExt1(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt1(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceEntityExt> selectExtList1(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt1(queryModel);
        return extList;
    }

    public CollectDeviceEntity selectEntity2(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt2(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceEntity> selectEntityList2(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt2(queryModel);
        if (extList == null) return null;
        List<CollectDeviceEntity> entityList = new ArrayList<>();
        for (CollectDeviceEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public CollectDeviceEntityExt selectExt2(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt2(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<CollectDeviceEntityExt> selectExtList2(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<CollectDeviceEntityExt> extList = collectDeviceEntityCustomMapper.selectExt2(queryModel);
        return extList;
    }

    public int selectCount(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = collectDeviceEntityCustomMapper.selectCount(queryModel);
        return count;
    }
    public int selectCount2(CollectDeviceCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = collectDeviceEntityCustomMapper.selectCount2(queryModel);
        return count;
    }
}
